import java.util.Scanner;

public class DigitsSum {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        System.out.println("请输入一个数：");
        int n = scan.nextInt();
        System.out.println("位数和为：" + sum(n));
    }

    public static int sum(int a) {
        int sum = 0;

        if (a < 10) {
            return a;
        } else {
            sum += a % 10 + sum(a / 10);
            return sum;
        }
    }
}
